home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CS Wallpap247048152001.psc / FrmMain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-08-15  |  27.4 KB  |  785 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
  4. Begin VB.Form FrmMain 
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "CS Wallpaper Changer"
  7.    ClientHeight    =   6540
  8.    ClientLeft      =   45
  9.    ClientTop       =   330
  10.    ClientWidth     =   9030
  11.    BeginProperty Font 
  12.       Name            =   "Times New Roman"
  13.       Size            =   8.25
  14.       Charset         =   0
  15.       Weight          =   400
  16.       Underline       =   0   'False
  17.       Italic          =   0   'False
  18.       Strikethrough   =   0   'False
  19.    EndProperty
  20.    Icon            =   "FrmMain.frx":0000
  21.    LinkTopic       =   "Form1"
  22.    MaxButton       =   0   'False
  23.    ScaleHeight     =   6540
  24.    ScaleWidth      =   9030
  25.    StartUpPosition =   2  'CenterScreen
  26.    Begin MSComDlg.CommonDialog CD1 
  27.       Left            =   120
  28.       Top             =   4680
  29.       _ExtentX        =   847
  30.       _ExtentY        =   847
  31.       _Version        =   393216
  32.    End
  33.    Begin MSComctlLib.StatusBar StatusBar1 
  34.       Align           =   2  'Align Bottom
  35.       Height          =   375
  36.       Left            =   0
  37.       TabIndex        =   15
  38.       Top             =   6165
  39.       Width           =   9030
  40.       _ExtentX        =   15928
  41.       _ExtentY        =   661
  42.       _Version        =   393216
  43.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  44.          NumPanels       =   3
  45.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  46.             AutoSize        =   1
  47.             Object.Width           =   10742
  48.             Text            =   "
  49.  Crofts Software - Networking Software & More"
  50.             TextSave        =   "
  51.  Crofts Software - Networking Software & More"
  52.          EndProperty
  53.          BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  54.             Style           =   6
  55.             Alignment       =   1
  56.             TextSave        =   "8/15/2001"
  57.          EndProperty
  58.          BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  59.             Style           =   5
  60.             Alignment       =   1
  61.             TextSave        =   "12:26 AM"
  62.          EndProperty
  63.       EndProperty
  64.    End
  65.    Begin VB.Frame Frame4 
  66.       Caption         =   "Advanced Options"
  67.       Height          =   1215
  68.       Left            =   120
  69.       TabIndex        =   12
  70.       Top             =   4920
  71.       Width           =   3495
  72.       Begin VB.CheckBox Check3 
  73.          Caption         =   "Minimize To System Tray At Startup"
  74.          Height          =   255
  75.          Left            =   120
  76.          TabIndex        =   14
  77.          Top             =   720
  78.          Width           =   3135
  79.       End
  80.       Begin VB.CheckBox Check2 
  81.          Caption         =   "Launch At Startup"
  82.          Height          =   255
  83.          Left            =   120
  84.          TabIndex        =   13
  85.          Top             =   360
  86.          Width           =   2655
  87.       End
  88.       Begin VB.Image Image1 
  89.          Height          =   480
  90.          Left            =   2880
  91.          Picture         =   "FrmMain.frx":1D2A
  92.          Top             =   240
  93.          Width           =   480
  94.       End
  95.    End
  96.    Begin VB.Frame Frame3 
  97.       Caption         =   "Wallpaper Options"
  98.       Height          =   1815
  99.       Left            =   128
  100.       TabIndex        =   6
  101.       Top             =   2880
  102.       Width           =   5280
  103.       Begin VB.Timer Timer2 
  104.          Interval        =   500
  105.          Left            =   4800
  106.          Top             =   1320
  107.       End
  108.       Begin VB.OptionButton Option6 
  109.          Caption         =   "Don't Change Wallpaper"
  110.          Height          =   255
  111.          Left            =   2640
  112.          TabIndex        =   21
  113.          Top             =   720
  114.          Value           =   -1  'True
  115.          Width           =   2055
  116.       End
  117.       Begin VB.OptionButton Option5 
  118.          Caption         =   "Change Wallpaper At Startup"
  119.          Height          =   255
  120.          Left            =   2640
  121.          TabIndex        =   20
  122.          Top             =   360
  123.          Width           =   2535
  124.       End
  125.       Begin VB.CheckBox Check4 
  126.          Caption         =   "Random Order"
  127.          Height          =   210
  128.          Left            =   2640
  129.          TabIndex        =   18
  130.          Top             =   1440
  131.          Width           =   2175
  132.       End
  133.       Begin VB.CheckBox Check1 
  134.          Caption         =   "Enable Wallpaper Preview"
  135.          Height          =   210
  136.          Left            =   2640
  137.          TabIndex        =   11
  138.          Top             =   1080
  139.          Value           =   1  'Checked
  140.          Width           =   2175
  141.       End
  142.       Begin VB.OptionButton Option4 
  143.          Caption         =   "Change Wallpaper Hourly"
  144.          Height          =   255
  145.          Left            =   120
  146.          TabIndex        =   10
  147.          Top             =   1440
  148.          Width           =   2175
  149.       End
  150.       Begin VB.OptionButton Option3 
  151.          Caption         =   "Change Wallpaper Daily"
  152.          Height          =   255
  153.          Left            =   120
  154.          TabIndex        =   9
  155.          Top             =   1080
  156.          Width           =   2175
  157.       End
  158.       Begin VB.OptionButton Option2 
  159.          Caption         =   "Change Wallpaper Weekly"
  160.          Height          =   255
  161.          Left            =   120
  162.          TabIndex        =   8
  163.          Top             =   720
  164.          Width           =   2535
  165.       End
  166.       Begin VB.OptionButton Option1 
  167.          Caption         =   "Change Wallpaper Monthly"
  168.          Height          =   255
  169.          Left            =   120
  170.          TabIndex        =   7
  171.          Top             =   360
  172.          Width           =   2415
  173.       End
  174.    End
  175.    Begin VB.Frame Frame2 
  176.       Caption         =   "Wallpaper List"
  177.       Height          =   2775
  178.       Left            =   128
  179.       TabIndex        =   3
  180.       Top             =   0
  181.       Width           =   8775
  182.       Begin VB.CommandButton Command3 
  183.          Caption         =   "Set as Wallpaper"
  184.          Height          =   255
  185.          Left            =   7200
  186.          TabIndex        =   19
  187.          Top             =   2400
  188.          Width           =   1455
  189.       End
  190.       Begin VB.CommandButton Command2 
  191.          Caption         =   "Remove"
  192.          Height          =   255
  193.          Left            =   960
  194.          TabIndex        =   17
  195.          Top             =   2400
  196.          Width           =   855
  197.       End
  198.       Begin VB.CommandButton Command1 
  199.          Caption         =   "Add"
  200.          Height          =   255
  201.          Left            =   120
  202.          TabIndex        =   16
  203.          Top             =   2400
  204.          Width           =   855
  205.       End
  206.       Begin VB.Timer Timer1 
  207.          Interval        =   100
  208.          Left            =   120
  209.          Top             =   240
  210.       End
  211.       Begin VB.ListBox List1 
  212.          Height          =   2160
  213.          Left            =   120
  214.          TabIndex        =   4
  215.          Top             =   240
  216.          Width           =   8535
  217.       End
  218.       Begin VB.Label Label1 
  219.          Alignment       =   2  'Center
  220.          Caption         =   "Total Wallpapers in list: 0"
  221.          Height          =   255
  222.          Left            =   120
  223.          TabIndex        =   5
  224.          Top             =   2400
  225.          Width           =   8535
  226.       End
  227.    End
  228.    Begin VB.Frame Frame1 
  229.       Caption         =   "Preview"
  230.       Height          =   3255
  231.       Left            =   5408
  232.       TabIndex        =   0
  233.       Top             =   2880
  234.       Width           =   3495
  235.       Begin VB.PictureBox picScreen 
  236.          AutoRedraw      =   -1  'True
  237.          BackColor       =   &H00000000&
  238.          BorderStyle     =   0  'None
  239.          Height          =   615
  240.          Left            =   120
  241.          ScaleHeight     =   41
  242.          ScaleMode       =   3  'Pixel
  243.          ScaleWidth      =   49
  244.          TabIndex        =   2
  245.          Top             =   240
  246.          Visible         =   0   'False
  247.          Width           =   735
  248.       End
  249.       Begin VB.PictureBox picPreview 
  250.          AutoRedraw      =   -1  'True
  251.          Height          =   2940
  252.          Left            =   120
  253.          ScaleHeight     =   192
  254.          ScaleMode       =   3  'Pixel
  255.          ScaleWidth      =   216
  256.          TabIndex        =   1
  257.          Top             =   240
  258.          Width           =   3300
  259.       End
  260.    End
  261.    Begin VB.Label Label2 
  262.       Alignment       =   2  'Center
  263.       Caption         =   "Date && Time Wallpaper Will Change."
  264.       Height          =   615
  265.       Left            =   3720
  266.       TabIndex        =   24
  267.       Top             =   4800
  268.       Width           =   1575
  269.    End
  270.    Begin VB.Label LblTime 
  271.       Alignment       =   2  'Center
  272.       Caption         =   "Time"
  273.       Height          =   255
  274.       Left            =   3720
  275.       TabIndex        =   23
  276.       ToolTipText     =   "Date & Time To Change The Wallpaper"
  277.       Top             =   5880
  278.       Width           =   1695
  279.    End
  280.    Begin VB.Label LblDate 
  281.       Alignment       =   2  'Center
  282.       Caption         =   "Date"
  283.       Height          =   255
  284.       Left            =   3720
  285.       TabIndex        =   22
  286.       ToolTipText     =   "Date & Time To Change The Wallpaper"
  287.       Top             =   5520
  288.       Width           =   1695
  289.    End
  290.    Begin VB.Menu MenuFile 
  291.       Caption         =   "&File"
  292.       Visible         =   0   'False
  293.       Begin VB.Menu MenuShow 
  294.          Caption         =   "&Show/Hide"
  295.       End
  296.       Begin VB.Menu MenuChange 
  297.          Caption         =   "&Change Wallpaper"
  298.       End
  299.       Begin VB.Menu MenuExit 
  300.          Caption         =   "&Exit Program"
  301.       End
  302.    End
  303. Attribute VB_Name = "FrmMain"
  304. Attribute VB_GlobalNameSpace = False
  305. Attribute VB_Creatable = False
  306. Attribute VB_PredeclaredId = True
  307. Attribute VB_Exposed = False
  308. 'Option Explicit
  309. Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
  310. Private Type NOTIFYICONDATA
  311.     cbSize As Long
  312.     hwnd As Long
  313.     uId As Long
  314.     uFlags As Long
  315.     uCallBackMessage As Long
  316.     hIcon As Long
  317.     szTip As String * 32
  318. End Type
  319. 'constants required by Shell_NotifyIcon API call:
  320. Private Const NIM_ADD = &H0
  321. Private Const NIM_MODIFY = &H1
  322. Private Const NIM_DELETE = &H2
  323. Private Const NIF_MESSAGE = &H1
  324. Private Const NIF_ICON = &H2
  325. Private Const NIF_TIP = &H4
  326. Private Const WM_MOUSEMOVE = &H200
  327. Private Const WM_LBUTTONDOWN = &H201     'Button down
  328. Private Const WM_LBUTTONUP = &H202       'Button up
  329. Private Const WM_LBUTTONDBLCLK = &H203   'Double-click
  330. Private Const WM_RBUTTONDOWN = &H204     'Button down
  331. Private Const WM_RBUTTONUP = &H205       'Button up
  332. Private Const WM_RBUTTONDBLCLK = &H206   'Double-click
  333. Private Const MAXLEN_IFDESCR = 256
  334. Private Const MAXLEN_PHYSADDR = 8
  335. Private Const MAX_INTERFACE_NAME_LEN = 256
  336. Private nid As NOTIFYICONDATA
  337. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
  338. Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
  339. Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
  340. Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
  341. Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
  342. Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
  343. Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
  344.     Const ERROR_SUCCESS = 0&
  345.     Const REG_SZ = 1 ' Unicode nul terminated String
  346.     Const REG_DWORD = 4 ' 32-bit number
  347. Public Enum HKeyTypes
  348.     HKEY_CLASSES_ROOT = &H80000000
  349.     HKEY_CURRENT_USER = &H80000001
  350.     HKEY_LOCAL_MACHINE = &H80000002
  351.     HKEY_USERS = &H80000003
  352.     HKEY_PERFORMANCE_DATA = &H80000004
  353. End Enum
  354. Private Declare Function ClipCursor Lib "user32" _
  355.     (lpRect As Any) As Long
  356. Private Declare Function OSGetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
  357. Private Declare Function OSGetPrivateProfileSection Lib "kernel32" Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
  358. Private Declare Function OSGetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
  359. Private Declare Function OSWritePrivateProfileSection Lib "kernel32" Alias "WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Long
  360. Private Declare Function OSWritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
  361. Private Declare Function OSGetProfileInt Lib "kernel32" Alias "GetProfileIntA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal nDefault As Long) As Long
  362. Private Declare Function OSGetProfileSection Lib "kernel32" Alias "GetProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long
  363. Private Declare Function OSGetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long
  364. Private Declare Function OSWriteProfileSection Lib "kernel32" Alias "WriteProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String) As Long
  365. Private Declare Function OSWriteProfileString Lib "kernel32" Alias "WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Long
  366. Private Const nBUFSIZEINI = 1024
  367. Private Const nBUFSIZEINIALL = 4096
  368. Private FilePathName As String
  369. Public Sub CleanUpSystray()
  370. Shell_NotifyIcon NIM_DELETE, nid
  371. End Sub
  372. Public Sub SaveSettings()
  373. Dim fFile As Integer
  374. fFile = FreeFile
  375. 'save settings
  376. Open App.Path & "\Settings.inf" For Output As fFile
  377. Print #fFile, "[settings]"
  378. Print #fFile, "monthly=" & Option1.Value
  379. Print #fFile, "weekly=" & Option2.Value
  380. Print #fFile, "daily=" & Option3.Value
  381. Print #fFile, "hourly=" & Option4.Value
  382. Print #fFile, "startup=" & Option5.Value
  383. Print #fFile, "nochange=" & Option6.Value
  384. Print #fFile, "preview=" & Check1.Value
  385. Print #fFile, "random=" & Check4.Value
  386. Print #fFile, "launchatstartup=" & Check2.Value
  387. Print #fFile, "minimize=" & Check3.Value
  388. Print #fFile, "lastpic=" & List1.ListIndex
  389. Print #fFile, "sdate=" & LblDate.Caption
  390. Print #fFile, "stime=" & LblTime.Caption
  391. Close fFile
  392. DoEvents
  393. End Sub
  394. Public Sub List_Add(list As ListBox, txt As String)
  395. On Error Resume Next
  396.     List1.AddItem txt
  397. End Sub
  398. Public Sub List_Load(thelist As ListBox, FileName As String)
  399.     'Loads a file to a list box
  400.     On Error Resume Next
  401.     Dim TheContents As String
  402.     Dim fFile As Integer
  403.     fFile = FreeFile
  404.     Open FileName For Input As fFile
  405.     Do
  406.         Line Input #fFile, TheContents$
  407.         If TheContents$ = "" Then
  408.         Else
  409.         Call List_Add(List1, TheContents$)
  410.         End If
  411.     Loop Until EOF(fFile)
  412.     Close fFile
  413. End Sub
  414. Public Sub List_Save(thelist As ListBox, FileName As String)
  415.     'Save a listbox as FileName
  416.     On Error Resume Next
  417.     Dim Save As Long
  418.     Dim fFile As Integer
  419.     fFile = FreeFile
  420.     Open FileName For Output As fFile
  421.     For Save = 0 To thelist.ListCount - 1
  422.         Print #fFile, List1.list(Save)
  423.     Next Save
  424.     Close fFile
  425. End Sub
  426. Private Sub SetPicture(ByVal FileName As String)
  427.     On Error GoTo Dawm
  428.     Dim xFile As String
  429.     xFile = WinPath & "CS WallPaper.bmp"
  430.     SavePicture picScreen.Picture, xFile
  431.     SystemParametersInfo SPI_SETDESKWALLPAPER, 0&, ByVal xFile, SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE
  432. Dawm:
  433. End Sub
  434. Private Sub Check2_Click()
  435. If Check2.Value = 1 Then
  436. Call AddToRun("CS Wallpaper Changer", App.Path & "\" & App.EXEName & ".exe")
  437. End If
  438. If Check2.Value = 0 Then
  439. Call RemoveFromRun("CS Wallpaper Changer")
  440. End If
  441. End Sub
  442. Private Sub Command1_Click()
  443. On Error GoTo dangit
  444. CD1.Filter = "Supported Picture Files|*.jpg;*.bmp;*.gif"
  445. CD1.CancelError = True
  446. CD1.ShowOpen
  447. List1.AddItem CD1.FileName
  448. Exit Sub
  449. dangit:
  450. End Sub
  451. Private Sub Command2_Click()
  452. On Error Resume Next
  453. List1.RemoveItem List1.ListIndex
  454. DoEvents
  455. End Sub
  456. Private Sub Command3_Click()
  457. SetPicture List1.Text
  458. End Sub
  459. Private Sub Form_Load()
  460. On Error Resume Next
  461. Dim AppDir As String
  462. AppDir = App.Path
  463. Me.Caption = "CS Wallpaper Changer v" & App.Major & "." & App.Minor & "." & App.Revision
  464. Call List_Load(List1, App.Path & "\WallpaperList.ini")
  465. DoEvents
  466. FilePathName = AppDir + "\Settings.inf"
  467. monthly = GetPrivateProfileString("settings", "monthly", "", FilePathName)
  468. weekly = GetPrivateProfileString("settings", "weekly", "", FilePathName)
  469. daily = GetPrivateProfileString("settings", "daily", "", FilePathName)
  470. hourly = GetPrivateProfileString("settings", "hourly", "", FilePathName)
  471. startup = GetPrivateProfileString("settings", "startup", "", FilePathName)
  472. nochange = GetPrivateProfileString("settings", "nochange", "", FilePathName)
  473. preview = GetPrivateProfileString("settings", "preview", "", FilePathName)
  474. random = GetPrivateProfileString("settings", "random", "", FilePathName)
  475. launchatstartup = GetPrivateProfileString("settings", "launchatstartup", "", FilePathName)
  476. minimize = GetPrivateProfileString("settings", "minimize", "", FilePathName)
  477. lastpic = GetPrivateProfileString("settings", "lastpic", "", FilePathName)
  478. sdate = GetPrivateProfileString("settings", "sdate", "", FilePathName)
  479. stime = GetPrivateProfileString("settings", "stime", "", FilePathName)
  480. DoEvents
  481. Option1.Value = monthly
  482. Option2.Value = weekly
  483. Option3.Value = daily
  484. Option4.Value = hourly
  485. Option5.Value = startup
  486. Option6.Value = nochange
  487. Check1.Value = preview
  488. Check2.Value = launchatstartup
  489. Check3.Value = minimize
  490. Check4.Value = random
  491. List1.ListIndex = lastpic
  492. LblDate.Caption = sdate
  493. LblTime.Caption = stime
  494. DoEvents
  495. DoEvents
  496. If Check3.Value = 1 Then
  497. Me.Hide
  498. End If
  499. With nid
  500. .cbSize = Len(nid)
  501. .hwnd = Me.hwnd
  502. .uId = vbNull
  503. .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
  504. .uCallBackMessage = WM_MOUSEMOVE
  505. .hIcon = Me.Icon
  506. nid.szTip = "CS Wallpaper Changer v" & App.Major & "." & App.Minor & "." & App.Revision
  507. End With
  508. Shell_NotifyIcon NIM_ADD, nid
  509. Timer2.Enabled = True
  510. End Sub
  511. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  512. Dim Result As Long
  513. Dim msg As Long
  514. If Me.ScaleMode = vbPixels Then
  515. msg = X
  516. msg = X / Screen.TwipsPerPixelX
  517. End If
  518. Select Case msg
  519. Case WM_LBUTTONDBLCLK    '515 restore form window
  520. If Me.Visible = True Then
  521. Me.Visible = False
  522. Me.Visible = True
  523. Me.SetFocus
  524. End If
  525. Case WM_RBUTTONUP        '517 display popup menu
  526. Me.PopupMenu Me.MenuFile
  527. End Select
  528. End Sub
  529. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  530. If UnloadMode = 0 Then
  531. Cancel = True
  532. End If
  533. Call List_Save(List1, App.Path & "\WallpaperList.ini")
  534. DoEvents
  535. FrmClose.Show
  536. End Sub
  537. Private Sub List1_Click()
  538. On Error GoTo dangit
  539. If Check1.Value = 1 Then
  540.     If 1 = 2 Then
  541.         picScreen.Cls
  542.         picScreen.PaintPicture LoadPicture(List1.Text), 0, 0, picScreen.ScaleWidth, picScreen.ScaleHeight
  543.     Else
  544.         Set picScreen.Picture = LoadPicture(List1.Text)
  545.     End If
  546.     picPreview.PaintPicture picScreen.Picture, 0, 0, picPreview.ScaleWidth, picPreview.ScaleHeight
  547.     picPreview.Refresh
  548. End If
  549. Exit Sub
  550. dangit:
  551.     If 1 = 2 Then
  552.         picScreen.Cls
  553.         picScreen.PaintPicture LoadPicture(App.Path & "\Error.jpg"), 0, 0, picScreen.ScaleWidth, picScreen.ScaleHeight
  554.     Else
  555.         Set picScreen.Picture = LoadPicture(App.Path & "\Error.jpg")
  556.     End If
  557.     picPreview.PaintPicture picScreen.Picture, 0, 0, picPreview.ScaleWidth, picPreview.ScaleHeight
  558.     picPreview.Refresh
  559. End Sub
  560. Private Sub MenuChange_Click()
  561. On Error Resume Next
  562.     If Check4.Value = 1 Then
  563.     List1.ListIndex = Int(Rnd * List1.ListCount)
  564.     Else
  565.     If List1.ListIndex = List1.ListCount - 1 Then
  566.     List1.ListIndex = 0
  567.     Else
  568.     List1.ListIndex = List1.ListIndex + 1
  569.     End If
  570.     End If
  571. DoEvents
  572. Call Command3_Click
  573. End Sub
  574. Private Sub MenuExit_Click()
  575. Call List_Save(List1, App.Path & "\WallpaperList.ini")
  576. DoEvents
  577. Call FrmMain.SaveSettings
  578. Call FrmMain.CleanUpSystray
  579. End Sub
  580. Private Sub MenuShow_Click()
  581. If Me.Visible = True Then
  582. Me.Visible = False
  583. Me.Visible = True
  584. Me.SetFocus
  585. End If
  586. End Sub
  587. Private Sub Option1_Click()
  588. Timer2.Enabled = True
  589. LblDate = Date + 30
  590. LblTime = "Time - Never"
  591. End Sub
  592. Private Sub Option2_Click()
  593. Timer2.Enabled = True
  594. LblDate = Date + 7
  595. LblTime = "Time - Never"
  596. End Sub
  597. Private Sub Option3_Click()
  598. Timer2.Enabled = True
  599. LblDate = Date + 1
  600. LblTime = "Time - Never"
  601. End Sub
  602. Private Sub Option4_Click()
  603. Timer2.Enabled = True
  604. LblDate.Caption = "Date - Never"
  605. LblTime.Caption = DateAdd("h", 1, Time)
  606. End Sub
  607. Private Sub Option5_Click()
  608. Timer2.Enabled = False
  609. LblDate.Caption = "Program Startup"
  610. LblTime.Caption = "Program Startup"
  611. End Sub
  612. Private Sub Option6_Click()
  613. Timer2.Enabled = False
  614. LblDate.Caption = "Date - Never"
  615. LblTime.Caption = "Time - Never"
  616. End Sub
  617. Private Sub Timer1_Timer()
  618. If List1.ListCount = 0 Then
  619. Command3.Enabled = False
  620. Command3.Enabled = True
  621. End If
  622. Me.Label1.Caption = "Total Wallpapers in list: " & List1.ListCount
  623. End Sub
  624. Private Sub Timer2_Timer()
  625. On Error Resume Next
  626. Dim xxx As Date
  627. Dim yyy As Date
  628. xxx = LblDate.Caption
  629. yyy = LblTime.Caption
  630. If Option1.Value = True Then
  631. Timer2.Enabled = True
  632. If xxx <= Date Then
  633.     If Check4.Value = 1 Then
  634.     List1.ListIndex = Int(Rnd * List1.ListCount)
  635.     Else
  636.     If List1.ListIndex = List1.ListCount - 1 Then
  637.     List1.ListIndex = 0
  638.     Else
  639.     List1.ListIndex = List1.ListIndex + 1
  640.     End If
  641.     End If
  642. LblDate = Date + 30
  643. DoEvents
  644. Call Command3_Click
  645. End If
  646. End If
  647. If Option2.Value = True Then
  648. Timer2.Enabled = True
  649. If xxx <= Date Then
  650.     If Check4.Value = 1 Then
  651.     List1.ListIndex = Int(Rnd * List1.ListCount)
  652.     Else
  653.     If List1.ListIndex = List1.ListCount - 1 Then
  654.     List1.ListIndex = 0
  655.     Else
  656.     List1.ListIndex = List1.ListIndex + 1
  657.     End If
  658.     End If
  659. LblDate = Date + 7
  660. DoEvents
  661. Call Command3_Click
  662. End If
  663. End If
  664. If Option3.Value = True Then
  665. Timer2.Enabled = True
  666. If xxx <= Date Then
  667.     If Check4.Value = 1 Then
  668.     List1.ListIndex = Int(Rnd * List1.ListCount)
  669.     Else
  670.     If List1.ListIndex = List1.ListCount - 1 Then
  671.     List1.ListIndex = 0
  672.     Else
  673.     List1.ListIndex = List1.ListIndex + 1
  674.     End If
  675.     End If
  676. LblDate = Date + 1
  677. DoEvents
  678. Call Command3_Click
  679. End If
  680. End If
  681. If Option4.Value = True Then
  682. Timer2.Enabled = True
  683. If yyy <= Time Then
  684.     If Check4.Value = 1 Then
  685.     List1.ListIndex = Int(Rnd * List1.ListCount)
  686.     Else
  687.     If List1.ListIndex = List1.ListCount - 1 Then
  688.     List1.ListIndex = 0
  689.     Else
  690.     List1.ListIndex = List1.ListIndex + 1
  691.     End If
  692.     End If
  693. LblTime.Caption = DateAdd("h", 1, Time)
  694. DoEvents
  695. Call Command3_Click
  696. End If
  697. End If
  698. If Option5.Value = True Then
  699. Timer2.Enabled = False
  700.     If Check4.Value = 1 Then
  701.     List1.ListIndex = Int(Rnd * List1.ListCount)
  702.     Else
  703.     If List1.ListIndex = List1.ListCount - 1 Then
  704.     List1.ListIndex = 0
  705.     Else
  706.     List1.ListIndex = List1.ListIndex + 1
  707.     End If
  708.     End If
  709. Call Command3_Click
  710. End If
  711. End Sub
  712. Private Function GetPrivateProfileString(ByVal szSection As String, ByVal szEntry As Variant, ByVal szDefault As String, ByVal szFileName As String) As String
  713.    ' *** Get an entry in the inifile ***
  714.    Dim szTmp                     As String
  715.    Dim nRet                      As Long
  716.    If (IsNull(szEntry)) Then
  717.       ' *** Get names of all entries in the named Section ***
  718.       szTmp = String$(nBUFSIZEINIALL, 0)
  719.       nRet = OSGetPrivateProfileString(szSection, 0&, szDefault, szTmp, nBUFSIZEINIALL, szFileName)
  720.    Else
  721.       ' *** Get the value of the named Entry ***
  722.       szTmp = String$(nBUFSIZEINI, 0)
  723.       nRet = OSGetPrivateProfileString(szSection, CStr(szEntry), szDefault, szTmp, nBUFSIZEINI, szFileName)
  724.    End If
  725.    GetPrivateProfileString = Left$(szTmp, nRet)
  726. End Function
  727. Private Function GetProfileString(ByVal szSection As String, ByVal szEntry As Variant, ByVal szDefault As String) As String
  728.    ' *** Get an entry in the WIN inifile ***
  729.    Dim szTmp                    As String
  730.    Dim nRet                     As Long
  731.    If (IsNull(szEntry)) Then
  732.       ' *** Get names of all entries in the named Section ***
  733.       szTmp = String$(nBUFSIZEINIALL, 0)
  734.       nRet = OSGetProfileString(szSection, 0&, szDefault, szTmp, nBUFSIZEINIALL)
  735.    Else
  736.       ' *** Get the value of the named Entry ***
  737.       szTmp = String$(nBUFSIZEINI, 0)
  738.       nRet = OSGetProfileString(szSection, CStr(szEntry), szDefault, szTmp, nBUFSIZEINI)
  739.    End If
  740.    GetProfileString = Left$(szTmp, nRet)
  741. End Function
  742. Public Sub AddToRun(ProgramName As String, FileToRun As String)
  743.     'Add a program to the 'Run at Startup' r
  744.     '     egistry keys
  745.     Call SaveString(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", ProgramName, FileToRun)
  746. End Sub
  747. Public Sub RemoveFromRun(ProgramName As String)
  748.     'Remove a program from the 'Run at Start
  749.     '     up' registry keys
  750.     Call DeleteValue(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", ProgramName)
  751. End Sub
  752. Public Sub SaveString(hKey As HKeyTypes, strPath As String, strValue As String, strdata As String)
  753.     'EXAMPLE:
  754.     '
  755.     'Call savestring(HKEY_CURRENT_USER, "Sof
  756.     '     tware\VBW\Registry", "String", text1.tex
  757.     '     t)
  758.     '
  759.     Dim keyhand As Long
  760.     Dim r As Long
  761.     r = RegCreateKey(hKey, strPath, keyhand)
  762.     r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strdata, Len(strdata))
  763.     r = RegCloseKey(keyhand)
  764. End Sub
  765. Public Function DeleteValue(ByVal hKey As HKeyTypes, ByVal strPath As String, ByVal strValue As String)
  766.     'EXAMPLE:
  767.     '
  768.     'Call DeleteValue(HKEY_CURRENT_USER, "So
  769.     '     ftware\VBW\Registry", "Dword")
  770.     '
  771.     Dim keyhand As Long
  772.     r = RegOpenKey(hKey, strPath, keyhand)
  773.     r = RegDeleteValue(keyhand, strValue)
  774.     r = RegCloseKey(keyhand)
  775. End Function
  776. Public Function DeleteKey(ByVal hKey As HKeyTypes, ByVal strPath As String)
  777.     'EXAMPLE:
  778.     '
  779.     'Call DeleteKey(HKEY_CURRENT_USER, "Soft
  780.     '     ware\VBW\Registry")
  781.     '
  782.     Dim keyhand As Long
  783.     r = RegDeleteKey(hKey, strPath)
  784. End Function
  785.